﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CluelessGame
{
    /// <summary>
    /// Interaction logic for JoinGameScreen.xaml
    /// </summary>
    public partial class JoinGameScreen : Window
    {
        static private IPEndPoint ipEndPoint = null;

        public JoinGameScreen()
        {
            InitializeComponent();
            ipTextBox.Text = "127.0.0.1";
            ipTextBox.Focus();
            ipTextBox.SelectAll();
        }

        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ipEndPoint = new IPEndPoint(IPAddress.Parse(ipTextBox.Text), 25654);
                Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }

        public static IPEndPoint GetIP()
        {
            JoinGameScreen joinGameScreen = new JoinGameScreen();
            joinGameScreen.ShowDialog();

            return ipEndPoint;
        }

        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
